package com.acwing.partition3;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/14 10:17
 */
@SuppressWarnings("all")
public class AC246区间最大公约数 {

    private static final int N = 500010;
    private static long[] nums = new long[N];
    private static Node[] tr = new Node[N << 2];

    private static int n = 0, m = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        ss = reader.readLine().split(" ");
        for (int i = 1; i <= n; i++) nums[i] = Long.parseLong(ss[i - 1]);
        build(1, 1, n);
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int l = Integer.parseInt(ss[1]), r = Integer.parseInt(ss[2]);
            if (ss[0].charAt(0) == 'Q') {
                Node left = query(1, 1, l), right = new Node(0, 0, 0, 0);
                if (l + 1 <= r) right = query(1, l + 1, r);
                writer.write(gcd(left.sum, right.maxv) + "\n");
            } else {
                long d = Long.parseLong(ss[3]);
                modify(1, l, d);
                if (r + 1 <= n) modify(1, r + 1, -d);
            }
        }
        writer.flush();
    }

    private static Node query(int u, int l, int r) {
        if (l <= tr[u].l && r >= tr[u].r) return tr[u];
        int mid = tr[u].l + tr[u].r >> 1;
        if (r <= mid) return query(u << 1, l, r);
        if (l > mid) return query(u << 1 | 1, l, r);
        Node left = query(u << 1, l, r), right = query(u << 1 | 1, l, r);
        Node res = new Node(-1, -1);
        pushup(res, left, right);
        return res;
    }

    private static void modify(int u, int x, long val) {
        if (tr[u].l == x && tr[u].r == x) {
            long v = tr[u].sum + val;
            tr[u].sum = tr[u].maxv = v;
        } else {
            int mid = tr[u].l + tr[u].r >> 1;
            if (x <= mid) modify(u << 1, x, val);
            else modify(u << 1 | 1, x, val);
            pushup(u);
        }
    }

    private static void pushup(int u) {
        pushup(tr[u], tr[u << 1], tr[u << 1 | 1]);
    }

    private static void pushup(Node u, Node l, Node r) {
        u.sum = l.sum + r.sum;
        u.maxv = gcd(l.maxv, r.maxv);
    }

    private static void build(int u, int l, int r) {
        if (l == r) {
            long val = nums[l] - nums[l - 1];
            tr[u] = new Node(l, r, val, val);
            return;
        }
        tr[u] = new Node(l, r);
        int mid = l + r >> 1;
        build(u << 1, l, mid);
        build(u << 1 | 1, mid + 1, r);
        pushup(u);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? Math.abs(a) : gcd(b, a % b);
    }

    private static class Node {
        private int l, r;
        //sum表示的原数，maxv表示当前区间内的最大公约数
        private long sum, maxv;

        public Node(int l, int r) {
            this.l = l;
            this.r = r;
        }

        public Node(int l, int r, long sum, long maxv) {
            this.l = l;
            this.r = r;
            this.sum = sum;
            this.maxv = maxv;
        }
    }
}
